package com.lc.rongzecaifu.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.lc.rongzecaifu.MyApplication;
import com.lc.rongzecaifu.rongzecaifu.R;
import com.zcx.helper.bound.BoundView;
import com.zcx.helper.bound.BoundViewHelper;

import java.util.List;

/**
 * Created by Administrator on 2017/3/16.
 */
public class BorrowManagerAdapter extends ArrayAdapter<String> {

    private LayoutInflater layoutInflater;
    private Context context;
    public int mType = 0;

    public BorrowManagerAdapter(Context context, List<String> entityLists) {
        super(context, 0, entityLists);

        this.context = context;
        this.layoutInflater = LayoutInflater.from(context);

    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        InviteBidsHolder inviteBidsHolder = null;
        MissBidsHolder missBidsHolder = null;
        PayOffHolder payOffHolder = null;
        OverdueHolder overdueHolder = null;

        if (convertView == null) {

            if (mType == 0) {

                convertView = BoundViewHelper.boundView(inviteBidsHolder = new InviteBidsHolder(), MyApplication.scaleScreenHelper.loadView((ViewGroup) layoutInflater.inflate(R.layout.item_invitebid_lists, null)));
                convertView.setTag(inviteBidsHolder);

            } else if (mType == 1) {

                convertView = BoundViewHelper.boundView(missBidsHolder = new MissBidsHolder(), MyApplication.scaleScreenHelper.loadView((ViewGroup) layoutInflater.inflate(R.layout.item_missbids_lists, null)));
                convertView.setTag(missBidsHolder);

            } else if (mType == 2) {

                convertView = BoundViewHelper.boundView(payOffHolder = new PayOffHolder(), MyApplication.scaleScreenHelper.loadView((ViewGroup) layoutInflater.inflate(R.layout.item_payoff_lists, null)));
                convertView.setTag(payOffHolder);

            } else if (mType == 3) {

                convertView = BoundViewHelper.boundView(overdueHolder = new OverdueHolder(), MyApplication.scaleScreenHelper.loadView((ViewGroup) layoutInflater.inflate(R.layout.item_overdue_lists, null)));
                convertView.setTag(overdueHolder);

            }

        } else {

            if (mType == 0) {

                inviteBidsHolder = (InviteBidsHolder) convertView.getTag();

            } else if (mType == 1) {

                missBidsHolder = (MissBidsHolder) convertView.getTag();

            } else if (mType == 2) {

                payOffHolder = (PayOffHolder) convertView.getTag();

            } else if (mType == 3) {

                overdueHolder = (OverdueHolder) convertView.getTag();

            }

        }

        switch (mType) {

            case 0:

//                inviteBidsHolder.item_invitebid_title_tv.setText("");
//                inviteBidsHolder.item_invitebid_payway_tv.setText("");
//                inviteBidsHolder.item_invitebid_percent_tv.setText("");
//                inviteBidsHolder.item_invitebid_money_tv.setText("");
//                inviteBidsHolder.item_invitebid_time_tv.setText("");

                break;

            case 1:

//                  missBidsHolder.item_missbid_title_tv.setText("");
//                  missBidsHolder.item_missbid_payway_tv.setText("");
//                  missBidsHolder.item_missbid_percent_tv.setText("");
//                  missBidsHolder.item_missbid_money_tv.setText("");
//                  missBidsHolder.item_missbid_time_tv.setText("");

                break;

            case 2:

//                payOffHolder.item_payoff_title_tv.setText("");
//                payOffHolder.item_payoff_payway_tv.setText("");
//                payOffHolder.item_payoff_timelimit_tv.setText("");
//                payOffHolder.item_payoff_money_tv.setText("");
//                payOffHolder.item_payoff_hadpay_tv.setText("");
//                payOffHolder.item_payoff_time_tv.setText("");
//                payOffHolder.item_payoff_detail_tv.setText("");

                break;

            case 3:

//                overdueHolder.item_overdue_title_tv.setText("");
//                overdueHolder.item_overdue_payway_tv.setText("");
//                overdueHolder.item_overdue_days_tv.setText("");//逾期天数
//                overdueHolder.item_overdue_payable_penalty_tv.setText("");//待付罚息
//                overdueHolder.item_overdue_capital_tv.setText("");//待还本金
//                overdueHolder.item_overdue_pending_interest_tv.setText("");//待还利息
//                overdueHolder.item_overdue_current_tv.setText("");//当前期数
//                overdueHolder.item_overdue_total_tv.setText("");//总期数
//                overdueHolder.item_overdue_prompt_charge_tv.setText("");//催收费
//                overdueHolder.item_overdue_total_money_tv.setText("");//待付总金额
//                overdueHolder.item_overdue_shouldpay_date_tv.setText("");//应还日期
//                overdueHolder.item_overdue_hadpay_date_tv.setText("");//已还日期

                break;

        }




        return convertView;
    }


    public class InviteBidsHolder {

        @BoundView(R.id.item_invitebid_title_tv) private TextView item_invitebid_title_tv;
        @BoundView(R.id.item_invitebid_payway_tv) private TextView item_invitebid_payway_tv;
        @BoundView(R.id.item_invitebid_percent_tv) private TextView item_invitebid_percent_tv;
        @BoundView(R.id.item_invitebid_money_tv) private TextView item_invitebid_money_tv;
        @BoundView(R.id.item_invitebid_time_tv) private TextView item_invitebid_time_tv;
    }

    public class MissBidsHolder {

        @BoundView(R.id.item_missbid_title_tv) private TextView item_missbid_title_tv;
        @BoundView(R.id.item_missbid_payway_tv) private TextView item_missbid_payway_tv;
        @BoundView(R.id.item_missbid_percent_tv) private TextView item_missbid_percent_tv;
        @BoundView(R.id.item_missbid_money_tv) private TextView item_missbid_money_tv;
        @BoundView(R.id.item_missbid_time_tv) private TextView item_missbid_time_tv;

    }
    public class PayOffHolder {

        @BoundView(R.id.item_payoff_title_tv) private TextView item_payoff_title_tv;
        @BoundView(R.id.item_payoff_payway_tv) private TextView item_payoff_payway_tv;
        @BoundView(R.id.item_payoff_timelimit_tv) private TextView item_payoff_timelimit_tv;
        @BoundView(R.id.item_payoff_money_tv) private TextView item_payoff_money_tv;
        @BoundView(R.id.item_payoff_hadpay_tv) private TextView item_payoff_hadpay_tv;
        @BoundView(R.id.item_payoff_time_tv) private TextView item_payoff_time_tv;
        @BoundView(R.id.item_payoff_detail_tv) private TextView item_payoff_detail_tv;

    }
    public class OverdueHolder  {


        @BoundView(R.id.item_overdue_title_tv) private TextView item_overdue_title_tv;
        @BoundView(R.id.item_overdue_payway_tv) private TextView item_overdue_payway_tv;
        @BoundView(R.id.item_overdue_days_tv) private TextView item_overdue_days_tv;
        @BoundView(R.id.item_overdue_payable_penalty_tv) private TextView item_overdue_payable_penalty_tv;
        @BoundView(R.id.item_overdue_capital_tv) private TextView item_overdue_capital_tv;
        @BoundView(R.id.item_overdue_pending_interest_tv) private TextView item_overdue_pending_interest_tv;
        @BoundView(R.id.item_overdue_current_tv) private TextView item_overdue_current_tv;
        @BoundView(R.id.item_overdue_total_tv) private TextView item_overdue_total_tv;
        @BoundView(R.id.item_overdue_prompt_charge_tv) private TextView item_overdue_prompt_charge_tv;
        @BoundView(R.id.item_overdue_total_money_tv) private TextView item_overdue_total_money_tv;
        @BoundView(R.id.item_overdue_shouldpay_date_tv) private TextView item_overdue_shouldpay_date_tv;
        @BoundView(R.id.item_overdue_hadpay_date_tv) private TextView item_overdue_hadpay_date_tv;

    }
}
